﻿@model OShop.ViewModels.ShippingZonesIndexViewModel
@using OShop.ViewModels

@{
    Style.Require("OShopAdmin");

    Layout.Title = T("Manage Shipping zones");
}

@using (Html.BeginFormAntiForgeryPost(Url.Action("Index", "ShippingZonesAdmin", new { area = "OShop", returnUrl = Context.Request.RawUrl }))) {

    <div class="manage">
        @Html.ActionLink(T("Create zone").Text, "Add", "ShippingZonesAdmin", new { Area = "OShop" }, new { @class = "button primaryAction" })
    </div>
    <fieldset class="bulk-actions">
        <label for="publishActions">@T("Actions:")</label>
        <select id="publishActions" name="BulkAction">
            @Html.SelectOption((ShippingZoneBulkAction)Model.BulkAction, ShippingZoneBulkAction.None, T("Choose action...").ToString())
            @Html.SelectOption((ShippingZoneBulkAction)Model.BulkAction, ShippingZoneBulkAction.Enable, T("Enable").ToString())
            @Html.SelectOption((ShippingZoneBulkAction)Model.BulkAction, ShippingZoneBulkAction.Disable, T("Disable").ToString())
            @Html.SelectOption((ShippingZoneBulkAction)Model.BulkAction, ShippingZoneBulkAction.Remove, T("Delete").ToString())
        </select>
        <button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button>
    </fieldset>
    <fieldset class="bulk-actions">
        <label for="contentResults" class="bulk-order">@T("Filter by")</label>
        <select id="contentResults" name="Filter">
            @Html.SelectOption((ShippingZoneFilter)Model.Filter, ShippingZoneFilter.All, T("All").ToString())
            @Html.SelectOption((ShippingZoneFilter)Model.Filter, ShippingZoneFilter.Enabled, T("Enabled").ToString())
            @Html.SelectOption((ShippingZoneFilter)Model.Filter, ShippingZoneFilter.Disabled, T("Disabled").ToString())
        </select>
        <button type="submit" name="submit.Filter" value="yes please">@T("Apply")</button>
    </fieldset>
    <fieldset>
        @if (Model.Zones.Any()) {
            <table class="items">
                <thead>
                    <tr>
                        <th scope="col"><input type="checkbox" class="check-all" /></th>
                        <th scope="col" style="width:100%;">@T("Name")</th>
                        <th scope="col">@T("Actions")</th>
                    </tr>
                </thead>
                @foreach (var record in Model.Zones) {
                    <tr>
                        <td>
                            <input type="checkbox" value="@record.Id" name="itemIds" />
                        </td>
                        <td scope="col">
                            @if (!record.Enabled) {
                                <img class="icon" src="@Href("~/Modules/OShop/Content/Admin/Images/Disabled.png")" alt="@T("Disabled")" title="@T("Disabled")" />
                            }
                            else {
                                <img class="icon" src="@Href("~/Modules/OShop/Content/Admin/Images/Enabled.png")" alt="@T("Enabled")" title="@T("Enabled")" />
                            }
                            @Html.ActionLink(record.Name, "Edit", "ShippingZonesAdmin", new { Area = "OShop", id = record.Id }, new { })
                        </td>
                        <td scope="col">
                            @Html.ActionLink(T("Edit").Text, "Edit", "ShippingZonesAdmin", new { Area = "OShop", id = record.Id }, new { })
                            @T(" | ")@Html.ActionLink(T("Delete").Text, "Delete", "ShippingZonesAdmin", new { Area = "OShop", id = record.Id, returnUrl = Context.Request.RawUrl }, new { itemprop = "RemoveUrl UnsafeUrl" })
                            @if (!record.Enabled) {
                                @T(" | ")@Html.ActionLink(T("Enable").Text, "Enable", "ShippingZonesAdmin", new { Area = "OShop", id = record.Id, returnUrl = Context.Request.RawUrl }, new { })

                            }
                            else {
                                @T(" | ")@Html.ActionLink(T("Disable").Text, "Disable", "ShippingZonesAdmin", new { Area = "OShop", id = record.Id, returnUrl = Context.Request.RawUrl }, new { })

                            }
                        </td>
                    </tr>
                }
            </table>
        }
        else {
            <p>@T("There is no shipping zone.")</p>
        }
    </fieldset>
    @Display(Model.Pager)
}